package com.tqhh.meimei.mapper;


import com.tqhh.meimei.model.Contents;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ContentsMapper {
    @Select("<script>" +
            "SELECT cid,title,slug,created,modified,text,`order`,authorId,template,type," +
            "`status`,`password`,commentsNum,allowComment,allowPing,allowFeed " +
            "FROM typecho_contents WHERE cid IN "
            + "<foreach item='item' index='index' collection='cids' open='(' separator=',' close=')'>"
            + "#{item}"
            + "</foreach>"
            + "</script>"
    )
    @Results({
            @Result(property = "cid", column = "cid"),
            @Result(property = "tags", column = "cid", many = @Many(select = "com.tqhh.meimei.mapper.TagMapper.findTagsByCid")),
            @Result(property = "categories", column = "cid", many = @Many(select = "com.tqhh.meimei.mapper.CategoryMapper.findCategoriesByCid"))
    })
    List<Contents> getArchives(@Param("cids") List<Long> cids);
}
